package com.zaofan.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.zaofan.bean.Activity;
import com.zaofan.bean.Lable;
import com.zaofan.dao.ActivityDao;

public class ActivityService {
	private ActivityDao activityDao = new ActivityDao();
	private LableService lableService = new LableService();

	public void delete(Activity activity) {
		activityDao.del(activity);
	}

	public void add(Activity activity) {
		Lable lable = lableService.findById(activity.getActivityLableId());
		activity.setActivityLableName(lable.getName());
		activity.setActivityCode(lable.getCode());
		lable = lableService.findById(activity.getScopeLableId());
		activity.setScopeLableName(lable.getName());
		activity.setScopeLableCode(lable.getCode());
		activity.setAddTime(new Date());
		activityDao.add(activity);
	}

	public void update(Activity activity) {
		activityDao.update(activity);
	}

	public List<Activity> findAll(Map<String, Object> params) {
		List<Activity> data = activityDao.findAll(params);
		if (data == null) {
			data = new ArrayList<>();
		}
		return data;
	}

	public Long count(Map<String, Object> params) {
		return activityDao.count(params);
	}

	public Activity findById(Integer id) {
		Map<String, Object> params = new HashMap<>();
		params.put("id", id);
		return activityDao.findOne(params);
	}
	
	public List<Activity> findTodayActivity(Integer shopId){
		return activityDao.findTodayActivity(shopId);
	}

	public List<Activity> findWholeActivity() {
		return activityDao.findWholeActivity();
	}

	public List<Activity> findShopActivity() {
		return activityDao.findShopActivity();
	}

}